package com.hs.controller;

import com.github.pagehelper.PageInfo;
import com.hs.entity.ConsultantTag;
import com.hs.service.ConsultantTagService;
import com.hs.util.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("consultanttag")
public class ConsultantTagController {
    @Autowired
    private ConsultantTagService consultantTagService;
    @PostMapping
    public R addConsultantTag(@RequestBody ConsultantTag consultantTag) {
        Integer i = consultantTagService.addconsultantTag(consultantTag);
        if (i > 0) {
            return R.ok();
        }else {
            return R.fail("失败");
        }
    }
    @DeleteMapping("{id}")
    public R deleteConsultantTag(@PathVariable("id") Integer id) {
        Integer i = consultantTagService.deleteconsultantTag(id);
        if (i > 0) {
            return R.ok();
        }else {
            return R.fail("失败");
        }
    }
    @PutMapping
    public R updateConsultantTag(@RequestBody ConsultantTag consultantTag) {
        Integer i = consultantTagService.updateconsultantTag(consultantTag);
        if (i > 0) {
            return R.ok();
        }else {
            return R.fail("失败");
        }
    }
    @GetMapping("{id}")
    public R getConsultantTagById(@PathVariable("id") Integer id) {
        List<ConsultantTag> consultantTag = consultantTagService.consultantTagById(id);
        return R.ok(consultantTag);
    }
    @GetMapping("page")
    public R getConsultantTagPage(Integer pageNum, Integer pageSize) {
        PageInfo<ConsultantTag> consultantTagByPage = consultantTagService.getConsultantTagByPage(pageNum, pageSize);
        return R.ok(consultantTagByPage);
    }
}
